/*
** flags.c for flags in /home/chassa_m/rendu/PSU_2013_my_printf
** 
** Made by chassa_m
** Login   <chassa_m@epitech.net>
** 
** Started on  Fri Nov 15 15:14:09 2013 chassa_m
** Last update Thu Nov 28 22:16:08 2013 chassa_m
*/

#include <stdarg.h>

int	flag_m(va_list ap)
{
  my_putstr("Success");
}

int	flag_s(va_list ap)
{
  my_putstr(va_arg(ap, char *));
}

int	flag_c(va_list ap)
{
  my_putchar((char) va_arg(ap, int));
}

int	flag_S(va_list ap)
{
  char	*str;

  str = va_arg(ap, char *);
  while (*str != '\0')
    {
      if (*str < 32 || *str >= 127)
	{
	  my_putchar('\\');
	  if (*str <= 7)
	    my_putstr("00");
	  else if (*str > 7 && *str < 32)
	    my_putchar('0');
	  my_putnbr_base(*str, "01234567");
	}
      else
	my_putchar(*str);
      str = str + 1;
    }
}

int	flag_percent(va_list ap)
{
  my_putchar('%');
}
